-
Notifications
You must be signed in to change notification settings - Fork 936
Feature/master/utils lite lambda trace #6404
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Conversation
9badcf1
to
85642fe
Compare
.../architecture-tests/src/test/java/software/amazon/awssdk/archtests/UtilsLitePackageTest.java
Show resolved
Hide resolved
...re/src/main/java/software/amazon/awssdk/awscore/interceptor/TraceIdExecutionInterceptor.java
Show resolved
Hide resolved
utils-lite/src/main/java/software/amazon/awssdk/utilslite/SdkInternalThreadLocal.java
Outdated
Show resolved
Hide resolved
...re/src/main/java/software/amazon/awssdk/awscore/interceptor/TraceIdExecutionInterceptor.java
Show resolved
Hide resolved
...re/src/main/java/software/amazon/awssdk/awscore/interceptor/TraceIdExecutionInterceptor.java
Show resolved
Hide resolved
utils-lite/src/main/java/software/amazon/awssdk/utilslite/SdkInternalThreadLocal.java
Outdated
Show resolved
Hide resolved
utils-lite/src/main/java/software/amazon/awssdk/utilslite/SdkInternalThreadLocal.java
Outdated
Show resolved
Hide resolved
utils-lite/src/main/java/software/amazon/awssdk/utilslite/SdkInternalThreadLocal.java
Show resolved
Hide resolved
Add utils-lite package
Add support for concurrent trace id propagation
18ce92a
to
8462a02
Compare
|
return context.httpRequest(); | ||
} | ||
|
||
@Override | ||
public void afterExecution(Context.AfterExecution context, ExecutionAttributes executionAttributes) { | ||
saveTraceId(executionAttributes); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not super obvious why we invoke saveTraceId in afterExecution and onExecutionFailure, can we add some javadocs?
|
||
@Override | ||
public void beforeExecution(Context.BeforeExecution context, ExecutionAttributes executionAttributes) { | ||
String traceId = SdkInternalThreadLocal.get(CONCURRENT_TRACE_ID_KEY); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we check lambdaFunctionNameEnvironmentVariable() and only check trace ID if it is a lambda function?
This PR adds:
SdkInternalThreadLocal
, a wrapper around threadLocal.Background
Previously, we implemented trace ID propagation using SLF4J's MDC in PR #6363, but this was
reverted because the MDC interface exists but the implementation is not provided by the SDK, Lambda runtime, or X-Ray SDK.
Solution
Added a small
utils-lite
utility class that provides thread local key value storage usingThreadLocal<Map<String, String>>
. For this case, it allows the Lambda Runtime Interface Client, AWS SDK, and X-Ray SDK to share trace context via this one package, but can extended to other use cases.Example: